package com.shilin.watchsystem.util;


import com.shilin.watchsystem.enums.ResultEnum;
import com.shilin.watchsystem.vo.ResultVO;

public class ResultUtil {

    public static ResultVO success(Object object) {
        ResultVO vo = new ResultVO();
        vo.setCode(200);
        vo.setStatus(vo.getCode());
        vo.setSuccess(true);
        vo.setMsg("ok");
        vo.setData(object);
        return vo;
    }

    public static ResultVO success() {
        return success(null);
    }

    public static ResultVO error(Integer code, String msg) {
        ResultVO vo = new ResultVO();
        vo.setSuccess(false);
        vo.setCode(code);
        vo.setStatus(code);
        vo.setMsg(msg);
        return vo;
    }

    public static ResultVO error(ResultEnum resultEnum) {
        ResultVO vo = error(resultEnum.getCode(), resultEnum.getMessage());
        return vo;
    }
}